package com.guagua.system.controller;

import com.guagua.common.response.Result;
import com.guagua.system.service.UploadService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/upload")
public class UploadController {
    private final UploadService uploadService;
    
    public UploadController(UploadService uploadService) {
        this.uploadService = uploadService;
    }
    
    @PostMapping
    public Result<String> upload(@RequestParam("file") MultipartFile file) {
        String url = uploadService.upload(file);
        return Result.success(url);
    }
    
    @DeleteMapping
    public Result<Void> delete(@RequestParam("fileUrl") String fileUrl) {
        uploadService.delete(fileUrl);
        return Result.success();
    }
} 